package Lee_code;

public class Lee_941_doublepointer {
    public boolean validMountainArray(int[] arr) {
        int len = arr.length;
        if (len < 3) return false;

        int left = 0;
        int right = len - 1;
        while (left < len-1) {
            if (arr[left] >= arr[left+1]) {
                break;
            }
            left++;
        }

        while (right > 0) {
            if (arr[right] >= arr[right-1]) {
                break;
            }
            right--;
        }

        if (left!=right) return false;

        return left != 0 && right != len - 1;
    }
}
